load mnist_knn;
load mnist_train;
load mnist_test;
k = 5;
X = [xL,xU]';
[n,d] = size(X);
idx = IDX(:,2:k+1);

W = zeros(n,k);
for i=1:n
    i
    Xn = X(idx(i,:),:)';
    W(i,:) = X(i,:)*Xn*inv(Xn'*Xn);
end
